package com.example.about_netty.channelhandler;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;

/*
Because the handler instance has a state variable which is dedicated to
 one connection, you have to create a new handler instance for each new
 channel to avoid a race condition where a unauthenticated client can get
 the confidential information:
 */
public class UnsharableServerInitializer extends ChannelInitializer<Channel> {
    @Override
    protected void initChannel(Channel channel) throws Exception {
        //为channel中的每个pipeline 添加一个新的 channelHandler 因为此时的handler 本身是含有状态的
        channel.pipeline().addLast("messageHandler", new UnsharableMessageHandler());
    }
}
